import http from './request.js'

// 三级联动区域的接口
export function reqCategoryList() {
    return http.get('/api/product/getBaseCategoryList')
}

// 调用mock模拟数据的接口
import mockhttp from './mockAjax.js'

export function reqBannerList() {
    return mockhttp.get('/banner')
}

export function reqFloorList() {
    return mockhttp.get('/floor')
}

// 获取search模块的接口
export function reqSearchInfo(params) {
    return http({
        url: "/api/list",
        method: 'post',
        data: params
    })
}

// 获取详情页数据的接口
export function reqDetailInfo(skuId) {
    return http.get(`/api/item/${skuId}`)
}

// 添加购物车
export function reqAddShopCart(skuId, skuNum) {
    return http.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}

// 获取购物车数据的接口
export function reqCartList() {
    return http.get('/api/cart/cartList')
}

// 删除购物车中某个商品
export function reqDeleteCartById(skuId) {
    return http.delete(`/api/cart/deleteCart/${skuId}`)
}

// 切换商品的选中状态
export function reqUpdateCheckedById(skuId, isChecked) {
    return http.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}

// 获取验证码
export function reqVerifyCode(phone) {
    return http.get(`/api/user/passport/sendCode/${phone}`)
}

// 注册
export function reqRegister(data) {
    return http({
        url: '/api/user/passport/register',
        method: 'post',
        data: data
    })
}

// 登录
export function reqLogin(user) {
    return http({
        url: '/api/user/passport/login',
        method: 'post',
        data: user
    })
}

// 获取用户信息
export function reqUserInfo() {
    return http.get('/api/user/passport/auth/getUserInfo')
}

// 退出登录
export function reqLogout() {
    return http.get('/api/user/passport/logout')
}

// 获取用户地址信息
export function reqUserAddressList() {
    return http.get('/api/user/userAddress/auth/findUserAddressList')
}

// 获取商品清单
export function reqOrderInfo() {
    return http.get('/api/order/auth/trade')
}

// 提交订单
export function reqSubmitOrder(tradeNo, data) {
    return http({
        url: `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'post',
        data: data
    })
}

// 获取支付信息
export function reqPayInfo(orderId) {
    return http.get(`/api/payment/weixin/createNative/${orderId}`)
}

// 支付状态
export function reqPayState(orderId) {
    return http.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}

// 获取个人中心数据
export function reqMyOrderList(page, limit) {
    return http.get(`/api/order/auth/${page}/${limit}`)
}